"""
    Zset类型API
"""
import redis

pool = redis.ConnectionPool(host="192.168.100.3" , port=6379 , decode_responses=True)

client = redis.Redis(connection_pool=pool)

client.flushdb()

# 插入：
client.zadd("z1" , "v1" , 20 , "v2" , 15 , "v3" , 25)
# 查询：
print(client.zrange("z1" , 0 , -1 , withscores=True))

# 范围查找：升序：
print(client.zremrangebyscore("z1" , 15 , 20))

# 范围查找：降序：
print(client.zremrangebyscore("z1" , 20 , 25))

# 增量：
client.zadd("z2" , 200 , 10)
print(client.zrange("z2" , 0 , -1 , withscores=True))
client.zincrby("z2" , 200 , 50)
print(client.zrange("z2" , 0 , -1 , withscores=True))









